package A04;

public class Test {
    public static void main(String[] args) {
   A03 a3 = new A03();
   int[] oldArr = {1,3,5,6,8};
   int[] newArr = a3.copyArr(oldArr);
        System.out.println("新数组的元素为:");
        for (int i = 0; i < newArr.length ; i++) {
            System.out.print(" "+ newArr[i]);
        }
    }
}

class A03{
    //功能：实现数组的复制，输入旧数组，返回新数组，元素不变
    //方法名copyArr
    //返回类型int[]
    //形参int[]
    public int[] copyArr(int[] oldArr){
        int[] newArr = new int[oldArr.length];

        for (int i = 0; i < oldArr.length; i++) {
            newArr[i] = oldArr[i];
        }
        return newArr;
    }
}
